package com.deep.spring.v29;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * https://blog.csdn.net/zwq_zwq_zwq/article/details/81059017
 */
//@Component
public class RunService implements CommandLineRunner {

    public void run(String... strings) {
        int i = 0;
        while (true) {
            i++;
            try {
                Thread.sleep(10000);
                System.out.println("过去了10秒钟……,i的值为：" + i);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (i == 4) { //第40秒时抛出一个异常
                throw new RuntimeException();
            }
            continue;
        }
    }
}